{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.metrics import classification_report  #对模型进行评估\n",
    "from sklearn import preprocessing  #对数据做标准化\n",
    "from sklearn.preprocessing import  PolynomialFeatures\n",
    "#数据是否需要标准化\n",
    "scale = False\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEACAYAAABVtcpZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X9wVeWdP/D3kyhTxBJ+BUirJMDXCGg71jbAshRuDVrp\nrku/trFgt0tdtrJ3aae/qMAUJ5dxLKubme/0ByAIVdGV9BsdlRbtV8FcKrOuyai01UHR1AuIgUT5\n4SKxQPL5/pF7w83l/jznOec855z3a+YO9yYn9zw53Dyf8/z6PEpEQERE4VTmdQGIiMg7DAJERCHG\nIEBEFGIMAkREIcYgQEQUYgwCREQhpiUIKKW2KKWOKqX+lOP7c5VSJ5RSryQfq3Wcl4iI7LlI0/s8\nAOCXALbmOeYPIvIPms5HREQaaGkJiMgeAMcLHKZ0nIuIiPRxc0zgb5RSe5VSO5RS01w8LxER5aCr\nO6iQlwFMEJHTSqn5AJ4EUOvSuYmIKAdXgoCInEp7/oxSar1SapSIHMs8VinFZEZERCUSEUtd7jq7\ngxRy9PsrpcalPZ8OQGULACkiwocIGhsbPS+DCQ9eB14LXov8Dzu0tASUUo8CiAAYrZQ6CKARwBAA\nIiKbAHxdKRUFcBZAD4Bv6DgvERHZoyUIiMitBb6/DsA6HeciIiJ9uGLYYJFIxOsiGIHX4Txei/N4\nLfRQdvuTdFNKiWllIiIymVIKYnFg2K0pokREqKmpwYEDB7wuhm9VV1cjkUhofU+2BIjINck7Vq+L\n4Vu5rp+dlgDHBIiIQoxBgIgoxBgEiIhCjEGAiChp4sSJeP755wseV1ZWhr/85S+WzmHnZ53AIEBE\nVCKlrGfGz/zZFStWYMyYMaisrMTKlSvtFq1knCJKRL5w5MgRPPzww+jp6cHNN9+Mq6++2rOy2Jnh\nlP6zGzduxPbt2/HnP/8ZADBv3jxMmjQJt99+u+0yFostASIywksvvYSmpiY8/PDDOHPmzKDvvfvu\nu/j856/GH/7wU+zbtwZz587ACy+84FhZ2tvbMWvWLIwcORKf/vSn8b3vfQ/nzp0bdMyOHTswefJk\njB07Fnfccceg7/3617/GtGnTMHr0aMyfPx8HDx7Mep6tW7fixz/+MaqqqlBVVYXly5fjwQcfdOrX\nys7r7HdZsuEJEQVTrr/vBx98QCorL5GGhovl858fJnPnzpAzZ84MfP9HP/q+3HJLubS2QlpbIatX\nQ+bM+cKg99i3b59Mn/4ZqagYKtOnf0b27dtXcvlqampk165d8sorr8hLL70kfX19cuDAAZk2bZr8\n/Oc/HzhOKSXXXXednDhxQg4dOiS1tbWyZcsWERF58skn5YorrpA333xTent75e6775ZZs2YN+tmO\njg4REamoqJC2traB77388ssyfPjwnOXLdf2SX7dU57IlQESeEhH84AfLcM89p/Fv/3YW9977EY4f\nfx3bt28fOObkyWMYP7534HVVFXDy5ImB16dPn8YNN8zBrFmv4aGHejBr1mu44YY5OH36tKUyfe5z\nn8P06dOhlMKECRNw++23Y/fu3YOOWblyJSoqKnDZZZfhBz/4AbZt2wagv4tn1apVqK2tRVlZGVau\nXIm9e/fi0KFDF5zn1KlTqKioGHg9fPhwnDp16oLjnMQgQESe6uvrw6lTH+Pyy/tfl5UBl1/ehw8+\n+GDgmAULGvD445fgjTeAw4eBzZsvwYIFtwx8f9++fRg69K9YsEBQUQEsWCAYOvSveOONNyyV6a23\n3sJNN92EqqoqjBgxAj/96U/x/vvvDzrmsssuG3heXV2N9957DwBw4MABfP/738eoUaMwatQojB49\nGkopHD58+ILzXHrppfjwww8HXp88eRK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qin1SvKx2otyukEptUUpdVQp9ac8x4Tlc5H3Wlj6\nXIiIZw8AVwK4AsDzAK7NcUwZgLcBVAO4GMBeAFO8LLdD1+IeAHckn68A8O85jvsLgJFel9eB37/g\n/zOA+QB2JJ/PAPDfXpfbw2sxF8B2r8vq0vWYDeAaAH/K8f1QfC6KvBYlfy48bQkIF5ulWwDgoeTz\nhwB8NcdxCsHM+VTM//MCAFsBQEReAlChlBqH4Cn2Mx+KSRQisgfA8TyHhOVzUcy1AEr8XPihMgnL\nYrOxInIUAETkCICxOY4TAM8ppdqVUt9xrXTOK+b/OfOYw1mOCYJiP/N/k+z+2KGUmuZO0YwUls9F\nsUr6XOicIpoVF5udl+daZOu3yzVi/7ci0qmUqkR/MNiXvDugcHkZwAQROa2Umg/gSQC1HpeJvFfy\n58LxICAi19t8i8MAJqS9viz5Nd/Jdy2Sgz3jROSoUmo8gK4c79GZ/LdbKfUE+rsOghAEivl/Pgzg\n8gLHBEHBayEip9KeP6OUWq+UGiUix1wqo0nC8rkoyMrnwqTuoIKLzZRSQ9C/2Gy7e8VyzXYA304+\nXwzgqcwDlFKXKKUuTT4fBuAGAK+5VUCHFfP/vB3APwEDK9FPpLrQAqbgtUjv81ZKTUf/dO8gBwCF\n3HVEWD4XKTmvhZXPheMtgXyUUl8F8EsAY9C/2GyviMxXSlUBuF9E/l5EepVSqcVmZQC2SDAXm90D\n4P8qpf4ZwAEAtwD9C++QvBbo70p6Ipla4yIA/ykiz3pVYJ1y/T8rpZb2f1s2icjTSqmvKKXeBvAR\ngNu8LLNTirkWAL6ulIoCOAugB8A3vCuxs5RSjwKIABitlDoIoBHAEITscwEUvhaw8LngYjEiohAz\nqTuIiIhcxiBARBRiDAJERCHGIEBEFGIMAkREIcYgQEQUYgwCREQhxiBARBRi/x8Cj/hTkV5KcwAA\nAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x2503726d0b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data = np.genfromtxt('LR-testSet2.txt',delimiter = ',')\n",
    "x_data = data[:,:-1]\n",
    "y_data = data[:,-1,np.newaxis]\n",
    "\n",
    "def plot():\n",
    "    x0 = []\n",
    "    y0 = []\n",
    "    x1 = []\n",
    "    y1 = []\n",
    "    \n",
    "    for i in range(len(x_data)):\n",
    "        if y_data[i] == 0:\n",
    "            x0.append(x_data[i,0])\n",
    "            y0.append(x_data[i,1])\n",
    "        else:\n",
    "            x1.append(x_data[i,0])\n",
    "            y1.append(x_data[i,1])\n",
    "    \n",
    "    #画图\n",
    "    scatter0 = plt.scatter(x0,y0,c='y',marker='o')\n",
    "    scatter1 = plt.scatter(x1,y1,c='g',marker='x')\n",
    "    #画图例\n",
    "    plt.legend(handles = [scatter0,scatter1],labels=['label0','label1'],loc ='best')\n",
    "    \n",
    "plot()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#定义多项式回归，degree的值可以调节多项式的特征\n",
    "poly_reg = PolynomialFeatures(degree = 3) \n",
    "#特征处理\n",
    "x_poly = poly_reg.fit_transform(x_data)  #degree = 3   x_poly  =  x^0  x^1  x^2  x^3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def sigmoid(x):\n",
    "    return 1.0/(1+np.exp(-x))\n",
    "\n",
    "def cost(Xmat,Ymat,ws):\n",
    "    left  = np.multiply(Ymat,np.log(sigmoid(Xmat*ws)))\n",
    "    right = np.multiply(1-Ymat,np.log(1-sigmoid(Xmat*ws)))\n",
    "    return np.sum(left+right) / -(len(Xmat))\n",
    "\n",
    "def gradAscent(Xarr,Yarr):\n",
    "    \n",
    "    if scale == True:\n",
    "        Xarr = preprocessing.scale(Xarr)\n",
    "    Xmat = np.mat(Xarr)\n",
    "    Ymat = np.mat(Yarr)\n",
    "    \n",
    "    lr = 0.03\n",
    "    epochs  =50000\n",
    "    costList = []\n",
    "    \n",
    "    m,n = np.shape(Xmat) #行代表数据的个数，列代表权值的个数\n",
    "    ws = np.mat(np.ones((n,1))) #初始化权值\n",
    "    \n",
    "    for i in range(epochs+1):\n",
    "        h = sigmoid(Xmat*ws)\n",
    "        ws_grad = Xmat.T*(h - Ymat)/m\n",
    "        ws = ws - lr *ws_grad\n",
    "        \n",
    "        if i % 50 ==0:\n",
    "            costList.append(cost(Xmat,Ymat,ws))\n",
    "        \n",
    "    return ws,costList"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 4.16787292]\n",
      " [ 2.72213524]\n",
      " [ 4.55120018]\n",
      " [-9.76109006]\n",
      " [-5.34880198]\n",
      " [-8.51458023]\n",
      " [-0.55950401]\n",
      " [-1.55418165]\n",
      " [-0.75929829]\n",
      " [-2.88573877]]\n"
     ]
    }
   ],
   "source": [
    "ws,costList = gradAscent(x_poly,y_data)\n",
    "print(ws)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD7CAYAAACPDORaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X14VNW1+PHvSkJ84xpIeJEoEoK1VisIEqS26gCtBVsv\nvkABraXSHyBo1YIKFr2E3toLglStoqhQlVq0Uiu+WysdbXurzRVBbcEiGkQIKolEAWWSsH9/nEky\nMzln5szMmcnkZH2ehyc5M2fO3oyyZs86e68txhiUUkr5U157d0AppVTmaJBXSikf0yCvlFI+pkFe\nKaV8TIO8Ukr5mAZ5pZTysYL27kAsEdE5nUoplSRjjNg9npMjeWMM8+fPxxijf5L8o++bvm/6vuX+\nH6/ft3hyMsgrpZTyhgZ5pZTysZwN8oFAo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LYHunXUUZBmwxxmwzxjQADwNj27lPHYIx5q/AJ+3dj47E\nGLPLGLMh/PteYBNwdKbbzdkgH2MK8Gx7d0L5ztHA9ojjD8jCPzqlRKQMOAV4NdNtFWS6gXhE5AWg\nd+RDgAHmGWOeDJ8zD2gwxvy2HbqYk9y8b0qp3CQiXYE1wFXhEX1GtWuQN8Z8K97zIvJD4BxgZFY6\n1EEket+UazuAYyOOjwk/plRGiEgBVoBfZYxZm402czZdIyKjgWuB/zTGHGjv/nRQmpePrwo4TkT6\niUghMBF4op371JEI+v9YslYC/zLG3JatBnM2yAO/AroCL4jIehFZ1t4d6ghE5DwR2Q4MB54SEb2X\n4cAY0wRcgTWT65/Aw8aYTe3bq45BRH4L/C9wvIi8LyKXtnefcp2IfB24GBgpIq+H49rojLerZQ2U\nUsq/cnkkr5RSKk0a5JVSysc0yCullI9pkFdKKR/TIK+UUj6mQV4ppXxMg7xSSvmYBnmllPKx/w/Z\ng9DD+Pu1zwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x250377fd7f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_min,x_max = x_data[:,0].min() -1,x_data[:,0].max()+1\n",
    "y_min,y_max = x_data[:,1].min() -1,x_data[:,1].max()+1\n",
    "\n",
    "#生成网格矩阵\n",
    "xx,yy = np.meshgrid(np.arange(x_min,x_max,0.02),np.arange(y_min,y_max,0.02))\n",
    "\n",
    "z = sigmoid(poly_reg.fit_transform(np.c_[xx.ravel(),yy.ravel()]).dot(np.array(ws)))\n",
    "for i in range(len(z)):\n",
    "    if z[i] > 0.5:\n",
    "        z[i] = 1\n",
    "    else:\n",
    "        z[i] = 0\n",
    "        \n",
    "z = z.reshape(xx.shape)\n",
    "#画等高线图\n",
    "cs = plt.contourf(xx,yy,z)\n",
    "plot()\n",
    "plt.show()\n",
    "    \n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             precision    recall  f1-score   support\n",
      "\n",
      "        0.0       0.86      0.83      0.85        60\n",
      "        1.0       0.83      0.86      0.85        58\n",
      "\n",
      "avg / total       0.85      0.85      0.85       118\n",
      "\n"
     ]
    }
   ],
   "source": [
    "def predict(x_data,ws):\n",
    "#     if scale == True:\n",
    "#       x_data = preprocessing.scale(x_data)\n",
    "     Xmat = np.mat(x_data)\n",
    "     ws = np.mat(ws)\n",
    "     return [1 if x >= 0.5 else 0 for x in sigmoid(Xmat*ws)]\n",
    "\n",
    "predictions = predict(x_poly,ws)\n",
    "\n",
    "print(classification_report(y_data,predictions))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
